<?php

abstract class openapi_api_function_base {

    function __construct() {
        // code...
    }

    public function apiData($flag, $data, $code, $msg) {
        $this->addslashes_fb($data);
        if ($flag) {
            $res['status'] = 'success';
            $res['data'] = $data;
        } else {
            $res['status'] = 'error';
            $res['data'] = $data;
        }
        $res['code'] = $code;
        $res['msg'] = $msg;
        return $res;
    }

    function addslashes_fb(&$aData) {
        if (is_array($aData)) {
            foreach ($aData as $k => &$ad) {
                $this->addslashes_fb($ad);
            }
        }
        if (is_string($aData)) {
            $aData = addslashes($aData);
        }
    }
}